package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.StrategyComment;
import cn.wolfcode.trip.base.domain.TravelReview;
import cn.wolfcode.trip.base.mapper.TravelReviewMapper;
import cn.wolfcode.trip.base.query.TravelReviewQueryObject;
import cn.wolfcode.trip.base.service.ITravelReviewService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TravelReviewServiceImpl implements ITravelReviewService {
    @Autowired
    private TravelReviewMapper travelReviewMapper;

    /**
     * 保存一条游记评论
     * @param travelReview
     */
    public void save(TravelReview travelReview) {
        travelReviewMapper.insert(travelReview);
    }

    /**
     * 更据游记查询对应的所有评论
     * 也可以根据用户id查询游记评论
     * @param qo 查询对象
     * @return
     */
    public PageInfo getCommentById(TravelReviewQueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize(),qo.getOrderBy());
        List list = travelReviewMapper.selectCommentById(qo);
        return new PageInfo(list);
    }
}